package com.kakaxi.mybilibili.module.home.drama.model;

import com.alibaba.fastjson.JSONObject;
import com.kakaxi.mybilibili.common.WebParamConst;
import com.kakaxi.mybilibili.common.WebUrlConst;
import com.kakaxi.mybilibili.net.FastJsonCacheRequest;
import com.kakaxi.mybilibili.net.Netroid;
import com.kakaxi.mybilibili.utils.URLUtil;
import com.vincestyling.netroid.Listener;

import java.util.HashMap;
import java.util.Map;

/**
 * 番剧主页面数据层实现类
 * Created by kakaxi on 16/10/19.
 */

public class DramaModel implements IDramaModel {

    @Override
    public void getSerializingData(Listener<JSONObject> listener) {
        Netroid.addRequest(new FastJsonCacheRequest(WebUrlConst.dramaSerializingUrl, null,
                listener, null), true);
    }

    @Override
    public void getRecommendData(String cursor, String pagesize, Listener<JSONObject> listener) {
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put(WebParamConst.REQUEST_PARAM_DRAMA_CURSOR, cursor);
        paramMap.put(WebParamConst.REQUEST_PARAM_DRAMA_PAGESIZE, pagesize);
        String finalUrl = URLUtil.addParamWithURL(WebUrlConst.dramaRecommendUrl, paramMap);
        Netroid.addRequest(new FastJsonCacheRequest(finalUrl, null, listener, null));
    }

    @Override
    public void getMoreRecommendData(Listener<JSONObject> listener) {
        Netroid.addRequest(new FastJsonCacheRequest(WebUrlConst.dramaRecommendMoreUrl, null,
                listener, null));
    }

}
